package init

import (
	"log"
	"lover/config"
	"lover/config/db"
	"time"
)

func DB() {
	now := time.Now()
	unmashal, err := config.Unmashal()
	if err != nil {
		panic(err)
	}
	log.Println(time.Since(now), "config success")
	db.InitDB(unmashal.DataBase)
	log.Println(time.Since(now), "database success")
	db.NewMysqlDB().AutoMigrate(
		entity.CloudPlan{},
		entity.CloudOrder{},
		entity.CloudNotice{},
		entity.CloudUser{},
		entity.CloudPayment{},
		entity.CloudLogTraffic{},
		entity.CloudServer{},
		entity.CloudKnowledge{},
	)
}
